<template>
    <div>
        <div>
            <mt-header id="header" title="选择用户角色">
            </mt-header>
        </div>
        <div class="select-role">
            <mt-button type="primary" @click="selectRole('sales')" id="primaryBtn" plain size="large">
                销售代表
            </mt-button>
            <mt-button type="primary" @click="selectRole('sales_manager')" id="primaryBtn" plain size="large">
                销售经理
            </mt-button>
            <mt-button type="primary" @click="selectRole('city_manager')" id="primaryBtn" plain size="large">
                城市经理
            </mt-button>
            <mt-button type="primary" @click="selectRole('city_manager_superior')" id="primaryBtn" plain size="large">
                地区销售总监
            </mt-button>
        </div>
    </div>
</template>

<script>
    import local from "../../util/local"
    export default {
        name: 'selectRole',
        data() {
            return {}
        },
        methods: {
            selectRole(roleType){
                let self = this
                this.$store.dispatch({
                    type: "updateRole",
                    roleType: roleType
                }).then(function (res) {
                    local.set(must_update_role, '0')
                    self.$router.push("/order")
                }, function (err) {

                })
            }
        },
        created(){
            if (!local.get('must_update_role')) {
                this.$router.push("/order")
            }
        }
    }
</script>
